from typing import *


class Solution:

    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        h = dict()
        ans = []
        for s in strs:
            c = "".join(sorted(s))
            if c in h:
                i = h.get(c)
                ans[i].append(s)
            else:
                h[c] = len(ans)
                ans.append([s])

        return ans


s = "cab"
print("".join(sorted(s)))